@echo off
set path=%path%;C:\Program Files (x86)\SEGGER\JLink_V640;
REM echo %path%

%~d0
cd /d %~dp0
ECHO ***********************************************************
set date_num=%date:~0,10%
set date_num=%date_num:-=%
set date_num=%date_num:/=%
set elf=%1_%date_num%.bin
copy %1.bin %elf%
copy bootloader.elf temp.bin
del appallfile.bin
jflash -opentemp.bin,0x8000000 -merge%elf%,0x8008000 -saveasappallfile.bin -exit
IF ERRORLEVEL 1 goto ERROR
goto END

:ERROR
ECHO ERRCODE:%ERRORLEVEL%
ECHO J-Flash Merge Error!
ECHO ***********************************************************
cmd
:END
del %1.bin
del temp.bin